/////////////////////////////////////////////////////////////////////////////
/// @file BiTree_TestSuite_helper.hpp
/// @ingroup
///
/// File containing the implementation of userclass which is support for
/// BiTree_TestSuite class.
/// Unit under test: (assistant class)
///
/// @see BiTree_TestSuite.cpp, BiTree_TestSuite.hpp
///
/// @if REVISION_HISTORY_INCLUDED
/// @par Edit History
/// @li [0]   zhalat 27-Jul-2014 Initial revision of file.
/// @endif
///
/// @par &copy;  2014 HalSoft
/////////////////////////////////////////////////////////////////////////////

#ifndef _BITREE_TESTSUITE_HELPER
#define _BITREE_TESTSUITE_HELPER

// SYSTEM INCLUDES
#include <iostream>
#include <iostream>
#include <fstream>
#include <sstream>      //for std::istringstream


//***************************************************************************
// Helper class definition for testing user class as part of tree
//***************************************************************************
class userclass
{
    public:
        //default constructor
        userclass( ){
            pdata = new std::string( "" );
        };
        //copy constructor
        userclass( const userclass& x ){
            pdata = new std::string( *x.pdata );
        }
        //constructor 1
        userclass( std::string s ){
            pdata = new std::string( s );
        }
        //overloaded operator '='
        //'this' means left object!
        userclass & operator = ( const userclass& x ){
            if(pdata != NULL)
                delete pdata;
            pdata = new std::string( *x.pdata );
            return *this;
        }
        //overloaded operator '=='
        bool operator==( const userclass& rhs) {
            return ( pdata->compare(*rhs.pdata) == 0 );
        }
        //converter: userclass -> char
        operator char();

        virtual ~userclass( ){
            if( NULL != pdata ){
                delete pdata;
            }
            pdata = NULL;
        }

    private:
        std::string *pdata;
        friend std::fstream & operator>>( std::fstream& fx, userclass& _x);
};

//overloaded operator '>>'
std::fstream & operator>>( std::fstream& fx, userclass& _x);

#endif//_BITREE_TESTSUITE_HELPER
